package com.webull.information.center.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webull.information.center.dao.InfoNewsLabelDao;
import com.webull.information.center.validator.NewsLabelValidator;
import com.webull.information.client.model.NewsLabel;
import com.webull.information.client.model.parm.NewsLabelParam;
import com.webull.information.client.service.InfoNewsLabelService;

/**
 * 新闻标签服务.
 *
 * @author longyang
 * @date 2016年6月27日 下午3:56:49
 * @version 1.0
 * @since JDK 1.8
 */
@Service
public class InfoNewsLabelServiceImpl implements InfoNewsLabelService {

	private @Autowired InfoNewsLabelDao infoNewsLabelDao;
	private @Autowired NewsLabelValidator newsLabelValidator;

	@Override
	public void add(NewsLabel label) {
		newsLabelValidator.validateAdd(label);
		infoNewsLabelDao.add(label);
	}

	@Override
	public void del(Integer id) {
		newsLabelValidator.validateDel(id);
		infoNewsLabelDao.del(id);
	}

	@Override
	public void update(NewsLabel label) {
		newsLabelValidator.validateUpdate(label);
		infoNewsLabelDao.update(label);
	}

	@Override
	public List<NewsLabel> paging(NewsLabelParam param) {
		return infoNewsLabelDao.paging(param);
	}

	@Override
	public List<NewsLabel> searchByIds(Integer[] labelIds) {
		if(labelIds.length==0)
			return new ArrayList<>();
		return infoNewsLabelDao.searchByIds(labelIds);
	}

	@Override
	public int count(NewsLabelParam param) {
		return infoNewsLabelDao.count(param);
	}

}
